package zj.xinxin.common.enums;

import org.springframework.util.CollectionUtils;

import java.util.*;
import java.util.function.Function;

/**
 * @author junzhou
 * @date 2022/3/23 16:29
 * @since 1.8
 */
public enum RoleLevelEnum {

    SUPER_ADMIN(1, "超级管理员"),
    ADMIN(2, "管理员"),
    CONSUMER(3, "用户"),
    DEFAULT(3, "用户");

    private final Integer roleCode;

    private final String groleName;


    RoleLevelEnum(Integer roleCode, String groleName) {
        this.roleCode = roleCode;
        this.groleName = groleName;
    }

    /**
     * 获取性别信息
     *
     * @param roleList 角色列表
     * @return 性别名称
     */
    public static String getGenderNameByCode(Integer code) {

        RoleLevelEnum roleLevelEnum = Arrays.stream(RoleLevelEnum.values())
                .filter(role -> Objects.equals(role.getRoleCode(), code))
                .findAny()
                .orElse(CONSUMER);

        return roleLevelEnum.getGroleName();
    }

    public Integer getRoleCode() {
        return roleCode;
    }

    public String getGroleName() {
        return groleName;
    }
}
